import numpy as np
import pandas as pd
import xlrd
import matplotlib.pyplot as plt

df = pd.read_excel('d:/dataset/十年期间国内旅游情况.xls', header=1)
data1 = df['年份'].T
data2 = df['国内游客（百万人次）'].T
data3 = df['城镇居民人均'].T
data4 = df['农村居民人均'].T

print(data2)

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

fig = plt.figure(figsize=(8, 6),dpi=100)

colors = ['r','g','b']
label = ['全国游客总人次','城镇居民游客人次','农村居民游客人次']

plt.fill_between(data1,y1=data2,y2=data3,
                 where=data2>=data3,
                 interpolate=True,
                 label=label[0],alpha=0.75,
                 facecolor=colors[0],linewidth=2,ec='k')

plt.fill_between(data1,y1=data3,y2=0,
                 label=label[1],alpha=0.75,
                 facecolor=colors[1],linewidth=2,ec='k')

plt.xlabel('年份')
plt.ylabel('游客人次')
plt.ylim(800,6100)

new_tick = np.array([i for i in range(2010, 2020)])
plt.xticks(new_tick)
plt.suptitle("2010-2019年全国,城镇,农村游客人次情况")
plt.title("单位:元", fontsize=10, loc='right')
fig.text(0.1, 0.02, s="数据来源:国家统计局")

plt.legend(loc=2)
plt.savefig('d:/image/task-25.png')
plt.show()